<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <title>订单查询</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'/>
    <%@include file="/WEB-INF/pages/common/taglib.jsp" %>
    <%@include file="/WEB-INF/pages/common/common.jsp" %>
</head>
<body>
<div class="content content_frame">
    <h3 class="mainTitle"><img src="${basePath}/images/icon2.png"/>订单管理</h3>
    </br>
    <ul class="contentNav dib-wrap">
        <li class="dib" id="btnSearch" defaultkey='13' onclick="reloadGrid()">
            <a><i class='fa fa-search'></i>&nbsp;&nbsp;查&nbsp;询 </a>
        </li>
        <li class="dib" onclick="importBtn();">
            <a><i class='fa fa-arrow-up'></i>&nbsp;&nbsp;导入</a>
        </li>
        <li class="dib" onclick="javascript:location.href='${basePath}/template/ORDERBILL.xls'">
            <a><i class='fa fa-arrow-down'></i>&nbsp;&nbsp;模板下载</a>
        </li>
        <li class="dib ">
            <a onclick="ClearAllInput('SearchTable')">
                <i class='fa fa-refresh'></i>&nbsp;&nbsp;重&nbsp;置 </a>
        </li>
    </ul>
    <br/>
    <table id="SearchTable" width="100%" class="table1">
        <tr>
            <td style="width: 25%;">
                <table width="100%" border="0" cellspacing="10" cellpadding="0">
                    <tr>
                        <td class="titleCss">
                            订单编号
                        </td>
                        <td class="tdCss">
                            <input type="text" placeholder="订单编号" datafield="SearchTable.orderId">
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 25%;">
                <table width="100%" border="0" cellspacing="10" cellpadding="0">
                    <tr>
                        <td class="titleCss">
                            贸易方式
                        </td>
                        <td class="tdCss">
                            <ui:tsingletableautocomplete
                                    keyFieldName="tradeMode"
                                    valueFieldName="tradeModeXXXX"
                                    tableName="DICT_ITEM"
                                    key="ITEM_KEY"
                                    value="ITEM_VALUE"
                                    groupId="TRADE_MODE_QDC"
                                    defaultKey="${orderHead.tradeMode}"
                                    defaultValue=""/>
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 25%;">
                <table width="100%" border="0" cellspacing="10" cellpadding="0">
                    <tr>
                        <td class="titleCss">
                            商户名称
                        </td>
                        <td class="tdCss">
                            <input type="text" placeholder="商户名称" datafield="SearchTable.ebName">
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 25%;">
                <table width="100%" border="0" cellspacing="10" cellpadding="0">
                    <tr>
                        <td class="titleCss">
                            买方名称
                        </td>
                        <td class="tdCss">
                            <input type="text" placeholder="买方名称" datafield="SearchTable.buyerName">
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td style="width: 25%;">
                <table width="100%" border="0" cellspacing="10" cellpadding="0">
                    <tr>
                        <td class="titleCss">
                            进出口类型
                        </td>
                        <td class="tdCss">
                            <ui:tsingletableautocomplete
                                    keyFieldName="orderType"
                                    valueFieldName="orderTypeXXXX"
                                    tableName="DICT_ITEM"
                                    key="ITEM_KEY"
                                    value="ITEM_VALUE"
                                    groupId="ieType"
                                    readonly="readonly"
                                    defaultKey="E"
                                    defaultValue=""/>
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 25%;">
                <table width="100%" border="0" cellspacing="10" cellpadding="0">
                    <tr>
                        <td class="titleCss">
                            入库日期
                        </td>
                        <td class="tdCss">
                            <input type="text" datafield="SearchTable.createTimeStart"
                                   id="createTimeStart"
                                   class="Wdate"
                                   onclick="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'createTimeEnd\')}'})">
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 25%;">
                <table width="100%" border="0" cellspacing="10" cellpadding="0">
                    <tr>
                        <td class="titleCss">
                            至
                        </td>
                        <td class="tdCss">
                            <input type="text" datafield="SearchTable.createTimeEnd"
                                   id="createTimeEnd"
                                   class="Wdate"
                                   onclick="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'createTimeStart\')}'})">
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 25%;">
                <table width="100%" border="0" cellspacing="10" cellpadding="0">
                    <tr>
                        <td class="titleCss">
                            操作状态
                        </td>
                        <td class="tdCss">
                            <ui:tsingletableautocomplete
                                    key="ITEM_KEY"
                                    value="ITEM_VALUE"

                                    tableName="DICT_ITEM"
                                    groupId="ORDER_STATUS_QDC"
                                    keyFieldName="status"
                                    valueFieldName="statusXXX"/>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <div class="cl"></div>
    <br/>
    <table id="corptable">
    </table>
    <div id="corptablePage">
    </div>
</div>
<form id="formId" action="${basePath}/uploadfile/doTemplateUpload" enctype="multipart/form-data" method="post">
    <input type="hidden" name="type" value="1">
    <input type="hidden" name="pages" value="declareManage/exportB2BDeclare/orderImportQdc/index">
    <input type="hidden" name="key" value="T_ORDER_HEAD_QDC">
    <input type="hidden" name="className" value="com.zz.ecommerce.common.bean.qdc.db.TOrderHeadQdc">
    <input type="file" id="file" name="file" style="display: none" onchange="upload(this.value);"/>
</form>
<script type="text/javascript">
    function detail(cellvalue, options, rowObject) {
        return $._options._detail($basePath + '/commonDetail/orderBillDetail?id=' + rowObject['id'], $.trim(cellvalue || ''));
    }

    $(function () {
        $("#corptable").jqGrid({
            datatype: "json",
            url: "${basePath}/exportB2B/orderManageQdc/queryOrderImportList",
            colNames: [
                'id',
                '操作状态',
                '订单编号',
                '进出口类型',
                '贸易方式',
                '商户代码',
                '商户名称',
                '商品总价',
                '币制',
                '买方名称',
                '买方证件类型',
                '买方证件号',
                '贸易国别',
                '买方电话',
                '收货地址',
                '电商平台代码',
                '备注',
                '入库日期'
            ],
            colModel: [
                {name: 'id', index: 'id', key: true, hidden: true},
                {name: 'status', index: 'status', formatter: status},
                {name: 'orderId', index: 'orderId', formatter: detail},
                {name: 'ieFlag', index: 'ieFlag', formatter: ieFlag},
                {name: 'tradeModeDisplay', index: 'tradeModeDisplay'},
                {name: 'ebCode', index: 'ebCode'},
                {name: 'ebName', index: 'ebName'},
                {name: 'totalPayment', index: 'totalPayment'},
                {name: 'currDisplay', index: 'currDisplay'},
                {name: 'buyerName', index: 'buyerName'},
                {name: 'buyerCertTypeDisplay', index: 'buyerCertTypeDisplay'},
                {name: 'buyerCertId', index: 'buyerCertId'},
                {name: 'buyerCountryDisplay', index: 'buyerCountryDisplay'},
                {name: 'buyerTel', index: 'buyerTel'},
                {name: 'deliveryAddr', index: 'deliveryAddr'},
                {name: 'ebPlatId', index: 'ebPlatId'},
                {name: 'note', index: 'note'},
                {name: 'createTime', index: 'createTime'}

            ],
            viewrecords: true, // show the current page, data rang and total records on the toolbar
            autowidth: true,
            height: 'auto',
            shrinkToFit: false,
            autoScroll: true,
            rowNum: 10, //每页显示记录数
            rowList: [10, 20, 100], //可调整每页显示的记录数
            rownumbers: true,
            rownumWidth: 35,
            width: $('body').width(),
            pager: "#corptablePage", //分页工具栏
            sortname: "createTime",
            sortorder: "desc",
            loadComplete: function () {
                var rowNum = $(this).jqGrid('getGridParam', 'records');
                if (rowNum <= 0) {
                    if ($(this).parent().children('.norecords').length == 0)
                        $(this).parent().append("<div class=\"norecords\">暂无数据！</div>");
                    $(this).parent().children('.norecords').show();
                }
                else {//如果存在记录，则隐藏提示信息。
                    $(this).parent().children('.norecords').hide();
                }
                $("#corptable").setGridWidth($(window).width() * 0.98);
                $(".ui-jqgrid tr.ui-row-ltr td").css('text-align', 'center');
            }
        });

        if (${not empty msg}) {
            layerAlertInfo('${msg}');
        }
    });

    function reloadGrid() {
        var jsonStr = customFormToData("SearchTable");
        $("#corptable").jqGrid('setGridParam', {
            url: "${basePath}/exportB2B/orderManageQdc/queryOrderImportList", postData: JSON.parse(jsonStr), //发送数据
            page: 1
        }).trigger("reloadGrid");
    }

    function importBtn() {
        document.getElementById('file').click();
    }

    function upload(address) {
        var AllowExt = ".xls,.xlsx";
        if (address == "") {
            return false;
        }
        var fileExt = address.substr(address.lastIndexOf(".")).toLowerCase();
        if (AllowExt != 0 && AllowExt.indexOf(fileExt) == -1) {
            ShowMessages("当前文件类型为" + fileExt + ",请上传" + AllowExt + "类型的文件!", "系统提示", "msgwaring", null, 0);
            return false;
        }
        $('#formId').submit();
    }
</script>
</body>
</html>
